/**
 * 
 */
package com.autosalon.ui.banka.action;

import com.autosalon.DAO.DaoFactory;
import com.autosalon.ui.banka.Banka;
import com.vaadin.ui.Button.ClickEvent;

/**
 * @author Ragisel
 *
 */
public class DeleteBankAction extends AbstractBankAction {

	private com.autosalon.model.Banka vybranaBanka;
	
	public DeleteBankAction(Banka banka) {
		super(banka);
	}

	@Override
	public void buttonClick(ClickEvent event) {

		vybranaBanka = (com.autosalon.model.Banka) DaoFactory
				.getinstance()
				.getBanka()
				.getById(Long.parseLong(event.getButton().getData().toString()));
		try {
            DaoFactory.getinstance().getBanka().delete(vybranaBanka);
            banka.getWindow().showNotification("Banka smázana");
            banka.naplnTabulkuObjednavky();
        } catch (NullPointerException e) {
            banka.getWindow().showNotification("Smazani neprobehlo korektne");
        }
	}

}
